﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using SIPO.Library.DomainObject.Administration;
using SIPO.Library.DataAccess.Administration;
using SIPO.Library.DomainObject.Transaction;
using SIPO.Library.DataAccess.Transaction;
using System.Configuration;
using SIPO.Library.DataAccess.Administration.Catalog;
using SIPO.Library.DomainObject.Administration.Catalog;
using System.Data;

namespace SIPO.Web.Reports.Transaction
{
public partial class rptRecCorporateAction : BasePage
{
    protected override void OnLoad(EventArgs e)
    {
        txtTahun.Text = DateTime.Now.Year.ToString();

        if (!IsPostBack)
        {
            //instansiasi controller
            recCorporateActionTypeRepo corporateActionTypeDal = new recCorporateActionTypeRepo(ConfigurationManager.ConnectionStrings["SIPOConn"].ConnectionString);
            recSectorRepo sectorDal = new recSectorRepo(ConfigurationManager.ConnectionStrings["SIPOConn"].ConnectionString);
            recSubSectorRepo subSectorDal = new recSubSectorRepo(ConfigurationManager.ConnectionStrings["SIPOConn"].ConnectionString);
            recSubSubSectorRepo subSubSectorDal = new recSubSubSectorRepo(ConfigurationManager.ConnectionStrings["SIPOConn"].ConnectionString);

            //instansiasi list object
            List<recCorporateActionType> corporateActionTypes = corporateActionTypeDal.GetList();
            List<recSector> sectors = sectorDal.GetList();
            List<recSubSector> subSectors = subSectorDal.GetList();
            List<recSubSubSector> subSubSectors = subSubSectorDal.GetList();

            //populate data recCorporateActionType
            ddlJenisAksiKorporasi.Items.Clear();
            if (corporateActionTypes.Count > 0)
            {
                corporateActionTypes.ForEach(delegate(recCorporateActionType corporateActionType)
                {
                    ddlJenisAksiKorporasi.Items.Add(new ListItem(corporateActionType.CorporateActionTypeID + " - " + corporateActionType.CorporateActionName, corporateActionType.CorporateActionTypeID.ToString()));
                });
            }
            ddlJenisAksiKorporasi.Items.Insert(0, new ListItem("-- pilih jenis aksi korporasi --",string.Empty));


            //populate data recSector
            ddlSektor.Items.Clear();
            if (sectors.Count > 0)
            {
                sectors.ForEach(delegate(recSector sector)
                {
                    ddlSektor.Items.Add(new ListItem(sector.SectorID + " - " + sector.SectorName, sector.SectorID.ToString()));
                });
            }
            ddlSektor.Items.Insert(0, new ListItem("-- pilih sektor --",string.Empty));

            //populate data recSubSector
            ddlSubSektor.Items.Clear();
            if (subSectors.Count > 0)
            {
                subSectors.ForEach(delegate(recSubSector subSector)
                {
                    ddlSubSektor.Items.Add(new ListItem(subSector.SubSectorID + " - " + subSector.SubSectorName, subSector.SubSectorID.ToString()));
                });
            }
            ddlSubSektor.Items.Insert(0, new ListItem("-- pilih sub sektor --",string.Empty));

            //populate data recSubSubSector
            ddlSubSubSektor.Items.Clear();
            if (subSubSectors.Count > 0)
            {
                subSubSectors.ForEach(delegate(recSubSubSector subSubSector)
                {
                    ddlSubSubSektor.Items.Add(new ListItem(subSubSector.SubSubSectorID + " - " + subSubSector.SubSubSectorName, subSubSector.SubSubSectorID.ToString()));
                });
            }
            ddlSubSubSektor.Items.Insert(0, new ListItem("-- pilih sub sub sektor --",string.Empty));
        }
    }
}
}